////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2008 Michiel Helvensteijn                                    //
//                                                                            //
// This file is part of the Mist compiler.                                    //
//                                                                            //
// The Mist compiler is free software: you can redistribute it and/or modify  //
// it under the terms of the GNU General Public License as published by       //
// the Free Software Foundation, either version 3 of the License, or          //
// (at your option) any later version.                                        //
//                                                                            //
// The Mist compiler is distributed in the hope that it will be useful,       //
// but WITHOUT ANY WARRANTY; without even the implied warranty of             //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              //
// GNU General Public License for more details.                               //
//                                                                            //
// You should have received a copy of the GNU General Public License          //
// along with the Mist compiler.  If not, see <http://www.gnu.org/licenses/>. //
////////////////////////////////////////////////////////////////////////////////

#ifndef CODEPOSITION_HPP
#define CODEPOSITION_HPP

/******************************************************************************
 * Includes                                                                   *
 ******************************************************************************/

#include <string>
using std::string;

#include <ostream>
using std::ostream;

#include <boost/operators.hpp>
using boost::partially_ordered;
using boost::equality_comparable;

namespace yy { class position; }

/******************************************************************************
 * CodePosition class                                                         *
 ******************************************************************************/

class CodePosition : public partially_ordered<CodePosition>, public equality_comparable<CodePosition> {
	public:
		
		CodePosition(const string& file = "", unsigned int line = 0, unsigned int column = 0);
		
		CodePosition(const yy::position& pos);
		
		void set_file(const string& file);
		const string& file() const;
		
		void set_line(unsigned int line);
		unsigned int line() const;
		
		void set_column(unsigned int column);
		unsigned int column() const;
		
		bool operator==(const CodePosition& other) const;
		
		bool operator<(const CodePosition& other) const;
		
		ostream& report_to_stream(ostream& stream) const;
	
	private:
		
		string       _file;
		unsigned int _line;
		unsigned int _column;
};

/******************************************************************************
 * Output Stream Operator                                                     *
 ******************************************************************************/

ostream& operator<<(ostream& stream, const CodePosition& pos);

#endif // CODEPOSITION_HPP
